unit F_Reporte_Copias_No_Impresas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, F_GeneralReport, DB, JvComponentBase, JvFormPlacement, StdCtrls,
  Grids, DBGrids, JvExDBGrids, JvDBGrid, JvDBUltimGrid, JvExControls,
  JvSpeedButton, ExtCtrls, ZAbstractRODataset, ZDataset, Mask, JvExMask,
  JvToolEdit, JvMaskEdit, JvCheckedMaskEdit, JvDatePickerEdit;

type
  TF_Reporte_NoImprimible = class(TF_ReporteGeneral)
    Label_Desde: TLabel;
    JvDPE_Desde: TJvDatePickerEdit;
    Label2: TLabel;
    JvDPE_Hasta: TJvDatePickerEdit;
    CB_FechaCreacion: TCheckBox;
    ZQ_Total: TZReadOnlyQuery;
    procedure CB_FechaCreacionClick(Sender: TObject);
    procedure B_CerrarClick(Sender: TObject);
    procedure JvSB_FiltrarClick(Sender: TObject);
    procedure B_GuardarClick(Sender: TObject);
    procedure JvDPE_DesdeKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure FiltrarLista;
  public
    { Public declarations }
  end;

implementation

uses R_Copias_No_Imprimibles, DM_Persistencia;

{$R *.dfm}

procedure TF_Reporte_NoImprimible.CB_FechaCreacionClick(Sender: TObject);
begin
  inherited;
  JvDPE_Desde.Enabled:= CB_FechaCreacion.Checked;
  JvDPE_Hasta.Enabled:= CB_FechaCreacion.Checked;
end;

procedure TF_Reporte_NoImprimible.B_CerrarClick(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TF_Reporte_NoImprimible.FiltrarLista;
var
  s:string;
begin
  inherited;
  with ZR_Consulta do
  begin
    Close;
    ZQ_Total.Close;
    JvDPE_Desde.DateFormat:= 'MM';
    ParamByName('MONTH_FROM').AsInteger:= StrToInt(JvDPE_Desde.Text);
    ZQ_Total.ParamByName('MONTH_FROM').AsInteger:= StrToInt(JvDPE_Desde.Text);
    JvDPE_Desde.DateFormat:= 'yyyy';
    ParamByName('YEAR_FROM').AsInteger:= StrToInt(JvDPE_Desde.Text);
    ZQ_Total.ParamByName('YEAR_FROM').AsInteger:= StrToInt(JvDPE_Desde.Text);
    JvDPE_Hasta.DateFormat:= 'MM';
    ParamByName('MONTH_TO').AsInteger:= StrToInt(JvDPE_Hasta.Text);
    ZQ_Total.ParamByName('MONTH_TO').AsInteger:= StrToInt(JvDPE_Hasta.Text);
    JvDPE_Hasta.DateFormat:= 'yyyy';
    ParamByName('YEAR_TO').AsInteger:= StrToInt(JvDPE_Hasta.Text);
    ZQ_Total.ParamByName('YEAR_TO').AsInteger:= StrToInt(JvDPE_Hasta.Text);
    Open;
    ZQ_Total.Open;
  end;
  JvDPE_Desde.DateFormat:= 'dd/MM/yyyy';
  JvDPE_Hasta.DateFormat:= 'dd/MM/yyyy';
end;


procedure TF_Reporte_NoImprimible.JvSB_FiltrarClick(Sender: TObject);
begin
  FiltrarLista;
end;

procedure TF_Reporte_NoImprimible.B_GuardarClick(Sender: TObject);
begin
  inherited;
  FiltrarLista;
  with TQ_RCopiasNoImprimibles.Create(Self) do
    try
      QR_CopiasNoImprimibles.Preview;
    finally
      QR_CopiasNoImprimibles.Free;
    end;
end;

procedure TF_Reporte_NoImprimible.JvDPE_DesdeKeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  if (Key = #13) then
    FiltrarLista;
end;

procedure TF_Reporte_NoImprimible.FormCreate(Sender: TObject);
begin
  inherited;
  FiltrarLista;
end;

end.
